#ifndef __MESSAGEHANDLE_H__
#define __MESSAGEHANDLE_H__

#include <iostream>
#include <string>
#include <unordered_map>
#include <functional>
#include "chatRoom.h"
#include "stdTcpServer.h"

class MessageHandler
{
public:
    using HandleFunction = std::function<void(const std::string &)>;

    // 构造函数
    MessageHandler(const StdTcpSocketPtr &client);
    // 析构函数
    ~MessageHandler();

public:
    // 处理信息
    void handleMessage(const std::string &msg);

private:
    ChatRoom m_chatroom;
    // 函数映射表
    std::unordered_map<int, HandleFunction> m_handles;

};

#endif // __MESSAGEHANDLE_H__